// ActionScript file

var LC_NAME = '_FlashProxy';
var FLASH_CONNECT = LC_NAME + '_IN';
var FLEX_CONNECT = LC_NAME + '_OUT';
var viewLoadTrgt;
_lockroot = true;
function init() {
	Stage.align = 'TL';
	Stage.scaleMode = 'noScale';
	in_lc = new LocalConnection();
	in_lc.resolve = mx.utils.Delegate.create(this, resolver);
	in_lc.ping = mx.utils.Delegate.create(this, ping);
	in_lc.connect(FLASH_CONNECT);
	out_lc = new LocalConnection();
	viewLoadTrgt = _root.createEmptyMovieClip('viewLoadTrgt', _root.getNextHighestDepth());
}

function ping() {
	out_lc.send(FLEX_CONNECT, 'ping');
}

function loader() {
	if (viewLoadTrgt.getBytesLoaded() > 0 && viewLoadTrgt.getBytesLoaded() >= viewLoadTrgt.getBytesTotal()) {
	out_lc.send(FLEX_CONNECT, 'onTargetLoaded');
	delete _root.onEnterFrame;
	}
}

function resolver() {
	var args:Array = arguments.slice(1, arguments.length);
	if (arguments[0] == 'loadMovie') {
		_root.onEnterFrame = mx.utils.Delegate.create(this, loader);
		_root.viewLoadTrgt.loadMovie(arguments[1]);
		return;
	}
	var numArgs = args.length;
	execFunc(_root.viewLoadTrgt, arguments[0], args);

	
}


function execFunc(target:Object, func:String, args:Array):Void
{
	target[func].apply(target, args);
}
init();